//
//  ONAlertView.m
//  OrderNow
//
//  Created by Familly on 2/25/14.
//  Copyright (c) 2014 Familly. All rights reserved.
//

#import "ONAlertView.h"

@implementation ONAlertView
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self = [[NSBundle mainBundle] loadNibNamed:@"ONAlertView" owner:self options:nil][0];
        _lbAlertView.text = NSLocalizedString(@"Whoops!", nil);
    }
    return self;
}

- (id)initWithFrame:(CGRect)frame andText:(NSString*)strText
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self = [[NSBundle mainBundle] loadNibNamed:@"ONAlertView" owner:self options:nil][0];
        _txtTextView.text=[NSString stringWithFormat:@"%@",strText];
        _lbAlertView.text = NSLocalizedString(@"Whoops!", nil);        
    }
    _bgView.layer.cornerRadius = 5;
    return self;
}
- (id)initWithFrame:(CGRect)frame andText:(NSString*)strText andLableView:(NSString*)strLable
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self = [[NSBundle mainBundle] loadNibNamed:@"ONAlertView" owner:self options:nil][0];
        _txtTextView.text=[NSString stringWithFormat:@"%@",NSLocalizedString(strText, nil)];
        _lbAlertView.text=[NSString stringWithFormat:@"%@",NSLocalizedString(strLable, nil)];
        _bgView.layer.cornerRadius = 5;
    }
    return self;
}

- (IBAction)btClickDismissAlertView:(id)sender {
    
    [UIView animateWithDuration:0.2f animations:^{
        [self setAlpha:0.0f];
    }completion:^(BOOL done){
        
        if (_delegate&& [_delegate respondsToSelector:@selector(clickButtonOk:)]){ //
            [_delegate clickButtonOk:sender];
        }
    
        [self removeFromSuperview];
        
        
    }];
    
}

-(void) layoutSubviews{
    [super layoutSubviews];
}

@end
